Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pruner): Implement full and bridge node pruning #3150

Merged
merged 35 commits into from
Mar 28, 2024

Conversation

renaynay
Copy link
Member

@renaynay renaynay commented Jan 31, 2024

This PR introduces full and bridge node pruning via the --experimental-pruning flag. Support is included for nodes that start from scratch with pruning enabled and also for archival (nodes retaining all historical blocks) that enable the --experimental-pruning flag.

Note that this PR does not support the conversion of a pruned node into an archival one explicitly (it would not support re-syncing deleted blocks).

With pruning enabled, full and bridge nodes' block stores can be expected not to exceed ~4TB (as the upper bound).

In follow-up PRs (hardening), the following features can be expected:

  • discovery for archival nodes for archival sync
  • inverted_index / light node pruning
  • include more metrics for errors

TODO:

  • clean up some TODOs
  • fix one flakey unit test
  • change values back to the actual (GC cycle, sampling window, pruning window, etc).
  • figure out whether to store error in pruner checkpoint
  • fix issue with pruning genesis block via findPruneableHeaders
  • metrics for failed prunes
  • set a sane default for max pruneable / consider removing MaxPruneablePerGC as now context timeouts are on a per block basis
  • dedup findPruneableHeader test utility
  • badger dep

@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 60.08584% with 93 lines in your changes are missing coverage. Please review.

Project coverage is 52.89%. Comparing base (1809680) to head (5918f6d).
Report is 6 commits behind head on main.

Files Patch % Lines
pruner/metrics.go 9.09% 30 Missing ⚠️
pruner/service.go 73.80% 18 Missing and 4 partials ⚠️
cmd/util.go 0.00% 14 Missing ⚠️
pruner/checkpoint.go 71.87% 5 Missing and 4 partials ⚠️
pruner/finder.go 83.78% 3 Missing and 3 partials ⚠️
header/headertest/testing.go 72.22% 4 Missing and 1 partial ⚠️
pruner/params.go 54.54% 5 Missing ⚠️
cmd/node.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3150      +/-   ##
==========================================
+ Coverage   51.92%   52.89%   +0.97%     
==========================================
  Files         178      183       +5     
  Lines       11316     9539    -1777     
==========================================
- Hits         5876     5046     -830     
+ Misses       4942     3980     -962     
- Partials      498      513      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renaynay renaynay marked this pull request as ready for review February 22, 2024 12:31
@renaynay
Copy link
Member Author

TODO @renaynay:

add some protection in finder.go to prevent

2024-02-28T16:10:59.333+0100	ERROR	pruner/service	pruner/service.go:129	failed to find prune-able blocks	{"error": "header/store: invalid range(26625,26624)"}

(can sometimes happen but is non-critical error, just ugly)

Copy link
Member

@walldiss walldiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most importantly all time calculations needs to take care of local machine zone, by using time.Now().UTC()

cmd/util.go Show resolved Hide resolved
nodebuilder/pruner/flags.go Outdated Show resolved Hide resolved
header/headertest/testing.go Outdated Show resolved Hide resolved
nodebuilder/pruner/config.go Show resolved Hide resolved
nodebuilder/pruner/module.go Show resolved Hide resolved
pruner/finder.go Outdated Show resolved Hide resolved
pruner/finder.go Outdated Show resolved Hide resolved
pruner/service.go Outdated Show resolved Hide resolved
pruner/service.go Outdated Show resolved Hide resolved
pruner/params.go Outdated Show resolved Hide resolved
@Wondertan
Copy link
Member

Wondertan commented Mar 11, 2024

@renaynay, there is a little conflict fyi

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is clean and well-structured. It wasn't hard to digest. I didn't find anything critical, and my review is primarily little nits I discovered and questions. There is one general comment about godocs for methods that need to be improved. Otherwise, :shipit:

pruner/metrics.go Outdated Show resolved Hide resolved
pruner/finder.go Outdated Show resolved Hide resolved
pruner/service_test.go Outdated Show resolved Hide resolved
pruner/service.go Show resolved Hide resolved
pruner/service.go Show resolved Hide resolved
pruner/finder.go Outdated Show resolved Hide resolved
pruner/finder.go Outdated Show resolved Hide resolved
pruner/metrics.go Show resolved Hide resolved
pruner/params.go Outdated Show resolved Hide resolved
pruner/service.go Outdated Show resolved Hide resolved
@celestiaorg celestiaorg deleted a comment from abstraking Mar 26, 2024
go.mod Outdated Show resolved Hide resolved
nodebuilder/pruner/config.go Show resolved Hide resolved
…her tests deterministic and test one more case for retries
…to proper values, sane MaxPruneable values, return gc cycle to every 5 min
@renaynay renaynay merged commit 02030bf into celestiaorg:main Mar 28, 2024
27 checks passed
@renaynay renaynay deleted the beta.5 branch March 28, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:storage kind:feat Attached to feature PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants